#ifndef _FILE_H
#define _FILE_H

#include <Windows.h>
#include <string>
#include <list>

using namespace std;

#define DEFAULT_NAME_FILE "files.html"

class CFile
{
public:
	typedef struct RECORD
	{
		string	file_name;
		bool	f_dir;
	};

private:
	string cur_path;

	list<string> list_drives;
	list<RECORD> list_files;

	string html_file_name;
	string html_page;

public:
	CFile();
	~CFile();

	inline void SetCurPath(const string path) { cur_path.assign(path); };
	inline string GetCurPath(){ return cur_path; };

	list<string> GetListDrives();
	list<RECORD> GetListFiles(const string path="");

	string GenHtmlListDrivesPage(const string srv_address);
	string GenHtmlListFilesPage(const string srv_address);
	void SaveHtmlListFilesPageToFile(const string file_name=DEFAULT_NAME_FILE);

	bool IsDir(const string path);
	string HttpPathToWinPath(string &http_path);

private:
	void del_dots_from_cur_path();
};

#endif